package com.budwk.app.sqfw.services.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.budwk.app.common.config.AppException;
import com.budwk.app.sqfw.dto.StatisticParamDTO;
import com.budwk.app.sqfw.models.Sqfw_cenSusPaper;
import com.budwk.app.sqfw.models.Sqfw_formSummary;
import com.budwk.app.sqfw.models.Sqfw_servicerecord;
import com.budwk.app.sqfw.services.*;
import com.budwk.app.sqfw.vo.*;
import com.budwk.app.sqfw.vo.dapingvo.*;
import com.budwk.app.sqfw.vo.dapingvo.SqfwRallyVO;
import com.budwk.app.sys.models.Sys_user;
import com.budwk.app.sys.services.SysUserService;
import com.budwk.app.util.adminUtils.CommonCheckUtils;
import com.budwk.app.util.poiUtils.CommonFormOfficeForAdminUtils;
import com.budwk.starter.security.utils.SecurityUtil;
import com.google.common.collect.Sets;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.sql.SqlCallback;
import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author LJT
 * @since 2023/10/26
 */
@IocBean
@Slf4j
public class SqfwDataStatisticForAdminServiceImpl implements SqfwDataStatisticForAdminService {
    private static final String ZHISHU = "直属";// 直属
    private static final String TIME_TYPE_CUSTOM = "00";// 自定义时间
    private static final String SIX_TYPE_SINGLE_OLD = "单独居老人";// 单独居老人
    private static final String SIX_TYPE_DOUBLE_OLD = "双独居老人";// 双独居老人
    private static final String SIX_TYPE_OLD = "老";// 老
    private static final String SIX_TYPE_VUL = "弱";// 弱
    private static final String SIX_TYPE_DISE = "病";// 病
    private static final String SIX_TYPE_DISA = "残";// 残
    private static final String SIX_TYPE_MENT = "疯";// 疯
    private static final String SIX_TYPE_DRINK = "酒";// 酒
    private static final String SPECIAL_TYPE_ONE = "鳏";// 鳏
    private static final String SPECIAL_TYPE_STAY = "留";// 留
    private static final String SPECIAL_TYPE_PREG = "孕";// 孕
    private static final String SPECIAL_TYPE_ENTERPRISE = "国有企业退休人员";// 国有企业退休人员

    @Inject
    private SqfwSummaryForAdminService sqfwSummaryForAdminService;

    @Inject
    private SqfwFormsummaryNewService sqfwFormsummaryNewService;

    @Inject
    private SqfwCenSusPaperService sqfwCenSusPaperService;

    @Inject
    private SysUserService sysUserService;

    @Inject
    private SqfwRallyForAdminService sqfwRallyForAdminService;

    @Inject
    private SqfwServicerecordService sqfwServicerecordService;

    @Inject("taskQueryExecutor")
    private ThreadPoolExecutor taskQueryExecutor;

    /**
     * 获取统计数据方法
     *
     * @param timeType
     * @return
     */
    @Override
    public List<SqfwDataStatisticStreetForAdminVO> getDataStatistic(String timeType) {
        if (Strings.isBlank(timeType)) {
            throw new AppException("请选择统计时间类型！");
        }
        Sys_user sysUser = sysUserService.fetch(SecurityUtil.getUserId());
        StatisticParamDTO statisticParamDTO = CommonCheckUtils.statisticTimeSectionByType(timeType);
        // 街道数据统计 (辖区内, 时间范围内)
        return getFinalCompareChangeForStreetData(statisticParamDTO, sysUser);
    }

    /**
     * 获取商铺数量
     *
     * @param sysUser
     * @return
     */
    @Override
    public Long getShopTotal() {
        Sys_user sysUser = sysUserService.fetch(SecurityUtil.getUserId());
        //数据库中存在这种"0001-01-01 00:00:00.000" 历史数据， 需要过滤掉
        StringBuffer sb = new StringBuffer("select count(1) shopTotal from (select distinct a1 from  shequ.\"sqfw_form_summary\" where  fill_date != '0001-01-01 00:00:00.000' and type LIKE '%安全排查%' ");
        processStatisticCond(sb, sysUser);
        sb.append(") t1");
        Sql sql = Sqls.create(sb.toString());
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                if (rs.next()) {
                    Long shopTotal = rs.getLong("shopTotal");
                    return shopTotal;
                }
                return 0;
            }
        });
        sqfwSummaryForAdminService.execute(sql);
        log.info("SQL-getShopTotal: province:{},city:{},district:{},county:{},community:{},sql:{},sqlREsult:{}", sysUser.getProvince(), sysUser.getCity(), sysUser.getDistrict(), sysUser.getCounty(), sysUser.getCommunity(), sql.toString(), sql.getLong());
        return sql.getLong();
    }

    /**
     * 获取辖区居民总数
     */
    @Override
    public Long getResidentTotal() {
        Sys_user sysUser = sysUserService.fetch(SecurityUtil.getUserId());
        //数据库中存在这种"0001-01-01 00:00:00.000" 历史数据， 需要过滤掉
        StringBuffer sb = new StringBuffer("select count(1) peopleTotal FROM shequ.\"sqfw_censuspaper\" WHERE 1 = 1 ");
        processStatisticCond(sb, sysUser);
        sb.append(" AND ((latest_status != '搬离' AND latest_status != '死亡') OR latest_status = '' OR latest_status is NULL)");
        Sql sql = Sqls.create(sb.toString());
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                if (rs.next()) {
                    Long peopleTotal = rs.getLong("peopleTotal");
                    return peopleTotal;
                }
                return 0;
            }
        });
        sqfwCenSusPaperService.execute(sql);
        log.info("SQL-getResidentTotal: province:{},city:{},district:{},county:{},community:{},sql:{},sqlREsult:{}", sysUser.getProvince(), sysUser.getCity(), sysUser.getDistrict(), sysUser.getCounty(), sysUser.getCommunity(), sql.toString(), sql.getLong());
        return sql.getLong();
    }

    /**
     * 六类人员数据统计
     */
    @Override
    public SqfwDataStatisticSixTypesForAdminVO getStatisticSixTypeData() {
        Sys_user sysUser = sysUserService.fetch(SecurityUtil.getUserId());
        Sql sql = null;
        SqfwDataStatisticSixTypesForAdminVO sqfwDataStatisSix = new SqfwDataStatisticSixTypesForAdminVO();
        // 统计当前周期数据
        StringBuffer sb = new StringBuffer("SELECT COUNT(1) nowTotal, special_mark sixType FROM shequ.\"sqfw_censuspaper\"  WHERE 1 = 1 ");
        processStatisticCond(sb, sysUser);
        sb.append(" AND (special_mark LIKE '%老%' OR special_mark LIKE '%弱%' OR special_mark LIKE '%病%' OR special_mark LIKE '%残%' OR special_mark LIKE '%酒%' OR special_mark LIKE '%疯%') GROUP BY special_mark");
        sql = Sqls.create(sb.toString());
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                ResultSetMetaData metaData = rs.getMetaData();
                int columnCount = metaData.getColumnCount();
                String sixType = "";
                Long nowData = 0L;
                SqfwDataStatisticSixTypesForAdminVO resultVO = new SqfwDataStatisticSixTypesForAdminVO();
                while (rs.next()) {
                    sixType = rs.getString("sixType");
                    nowData = rs.getLong("nowTotal");
                    switch (sixType) {
                        case SIX_TYPE_DOUBLE_OLD:
                            resultVO.setOldDoubleTotal(nowData);
                            break;
                        case SIX_TYPE_SINGLE_OLD:
                            resultVO.setOldSingleTotal(nowData);
                            break;
                        case SIX_TYPE_OLD:
                            resultVO.setOldTotal(nowData);
                            break;
                        case SIX_TYPE_DISA:
                            resultVO.setDisabledTotal(nowData);
                            break;
                        case SIX_TYPE_VUL:
                            resultVO.setVulTotal(nowData);
                            break;
                        case SIX_TYPE_MENT:
                            resultVO.setMentalTotal(nowData);
                            break;
                        case SIX_TYPE_DISE:
                            resultVO.setDiseaseTotal(nowData);
                            break;
                        case SIX_TYPE_DRINK:
                            resultVO.setDrinkTotal(nowData);
                            break;
                        default:
                            // 累计复合六类人员
                            sumSixTypeMixPeopelNum(resultVO, sixType, nowData);
                    }
                }
                resultVO.setOldTotal(resultVO.getOldTotal() + resultVO.getOldSingleTotal() + resultVO.getOldDoubleTotal());
                resultVO.setSixTotal(resultVO.getOldTotal() + resultVO.getDisabledTotal() + resultVO.getVulTotal() + resultVO.getMentalTotal() + resultVO.getDiseaseTotal() + resultVO.getDrinkTotal());
                return resultVO;
            }
        });
        sqfwCenSusPaperService.execute(sql);
        sqfwDataStatisSix = sql.getObject(SqfwDataStatisticSixTypesForAdminVO.class);
        log.info("SQL-getStatisticSixTypeData: province:{},city:{},district:{},county:{},community:{},sql:{},sqlREsult:{}", sysUser.getProvince(), sysUser.getCity(), sysUser.getDistrict(), sysUser.getCounty(), sysUser.getCommunity(), sql.toString(), JSONObject.toJSONString(sqfwDataStatisSix));
        return sqfwDataStatisSix;
    }

    /**
     * 具体统计SQL方法
     * @param startTime
     * @param endTime
     * @param sysUser
     * @param sqfwDataStatisticStreet
     * @param streetCommunityList
     */
    private void getCompareChangeForStreetData(
            Date startTime,
            Date endTime,
            Sys_user sysUser,
            SqfwDataStatisticStreetForAdminVO sqfwDataStatisticStreet,
            List<SqfwDataStatisticStreetForAdminVO> streetCommunityList) {
        SqfwDataStatisticStreetForAdminVO finalResSix = new SqfwDataStatisticStreetForAdminVO();
        Sys_user sysUserStreet = new Sys_user();
        sysUserStreet.setCounty(sqfwDataStatisticStreet.getCounty());
        sysUserStreet.setCommunity(sqfwDataStatisticStreet.getCommunity());
        if (ObjectUtil.isNotEmpty(sysUser) && ZHISHU.equals(sysUser.getCounty())) {
            sysUserStreet.setCommunity("");
        }
        // 统计街道巡查情况
        SqfwDataStatisticStreetForAdminVO sqfwDataStatisticStreetForAdminVO = new SqfwDataStatisticStreetForAdminVO();
        sqfwDataStatisticStreetForAdminVO = getStreetDeadlineRectForStreetData(startTime, endTime, sysUserStreet);
        finalResSix.setCounty(sqfwDataStatisticStreet.getCounty());
        finalResSix.setCommunity(sqfwDataStatisticStreet.getCommunity());
        finalResSix.setSceneRectTotal(sqfwDataStatisticStreetForAdminVO.getSceneRectTotal());
        finalResSix.setShopCheckTotal(sqfwDataStatisticStreetForAdminVO.getShopCheckTotal());
        finalResSix.setDeadlineRectTotal(sqfwDataStatisticStreetForAdminVO.getDeadlineRectTotal());
        finalResSix.setHiddenDangerTotal(sqfwDataStatisticStreetForAdminVO.getHiddenDangerTotal());
        finalResSix.setGasCheckTotal(sqfwDataStatisticStreetForAdminVO.getGasCheckTotal());
        finalResSix.setGarbageCheckTotal(sqfwDataStatisticStreetForAdminVO.getGarbageCheckTotal());
        finalResSix.setCheckTimeOutTotal(sqfwDataStatisticStreetForAdminVO.getCheckTimeOutTotal());
        finalResSix.setHiddenDangerTimes(sqfwDataStatisticStreetForAdminVO.getHiddenDangerTimes());
        if (Strings.isNotBlank(finalResSix.getCounty()) || Strings.isNotBlank(finalResSix.getCommunity())) {
            streetCommunityList.add(finalResSix);
        }
    }

    /**
     * 较上一周期时间变化数据(街道数据统计)
     */
    private List<SqfwDataStatisticStreetForAdminVO> getFinalCompareChangeForStreetData(StatisticParamDTO statisticParamDTO, Sys_user sysUser) {
        Date startTime = statisticParamDTO.getStartTime();
        Date endTime = statisticParamDTO.getEndTime();
        Date lastStartTime = statisticParamDTO.getLastStartTime();
        Date lastEndTime = statisticParamDTO.getLastEndTime();
        // 街道社区列表统计(先统计出sys_user中的社区信息，然后再去查询具体的六类和商铺信息)
        List<SqfwDataStatisticStreetForAdminVO> sysUserCommunityList = getUserCommunityInfo(sysUser);
        if (sysUserCommunityList.size() <= 0) {
            return new ArrayList<SqfwDataStatisticStreetForAdminVO>();
        }
        log.info("distinctItems community：{}", sysUserCommunityList.size());
        List<SqfwDataStatisticStreetForAdminVO> finalResultStreetList = Collections.synchronizedList(new ArrayList<SqfwDataStatisticStreetForAdminVO>());
        // 如果街道是直属，则用街道去重之后进行统计，不用每个社区都查询，提升效率
        Sys_user sysUserHost = sysUserService.fetch(SecurityUtil.getUserId());
        if (ObjectUtil.isNotEmpty(sysUserHost) && ZHISHU.equals(sysUserHost.getCounty())) {
            sysUserCommunityList = new ArrayList<>(sysUserCommunityList.stream().collect(Collectors.toMap(SqfwDataStatisticStreetForAdminVO::getCounty, Function.identity(), (existing, replacement) -> existing)).values());
            log.info("distinctItems county：{}", sysUserCommunityList.size());
        }
        // 计算变化情况
        CompletableFuture[] cf = sysUserCommunityList.stream().map(item -> CompletableFuture.runAsync(() ->
                        getCompareChangeForStreetData(startTime, endTime, sysUser, item, finalResultStreetList), taskQueryExecutor)
                .thenApply(r -> r)).toArray(CompletableFuture[]::new);
        CompletableFuture.allOf(cf).join();

        if (null != sysUserHost && ZHISHU.equals(sysUserHost.getCounty())) {
            Map<String, List<SqfwDataStatisticStreetForAdminVO>> finalResultStreetGroupMap = finalResultStreetList.stream().collect(Collectors.groupingBy(SqfwDataStatisticStreetForAdminVO::getCounty, HashMap::new, Collectors.toList()));
            List<SqfwDataStatisticStreetForAdminVO> finalResultStreetGroupList = new ArrayList<SqfwDataStatisticStreetForAdminVO>();
            finalResultStreetGroupMap.forEach((key, value) -> {
                SqfwDataStatisticStreetForAdminVO streetValueTmp = new SqfwDataStatisticStreetForAdminVO();
                streetValueTmp.setCounty(key);
                streetValueTmp.setCommunity(value.get(0).getCommunity());
                value.forEach(item -> {
                    streetValueTmp.setSixTypesOut(streetValueTmp.getSixTypesOut() + item.getSixTypesOut());
                    streetValueTmp.setTotal(streetValueTmp.getTotal() + item.getTotal());
                    streetValueTmp.setGasCheckTotal(streetValueTmp.getGasCheckTotal() + item.getGasCheckTotal());
                    streetValueTmp.setHiddenDangerTotal(streetValueTmp.getHiddenDangerTotal() + item.getHiddenDangerTotal());
                    streetValueTmp.setSixTypesDead(streetValueTmp.getSixTypesDead() + item.getSixTypesDead());
                    streetValueTmp.setDeadlineRectTotal(streetValueTmp.getDeadlineRectTotal() + item.getDeadlineRectTotal());
                    streetValueTmp.setSceneRectTotal(streetValueTmp.getSceneRectTotal() + item.getSceneRectTotal());
                    streetValueTmp.setShopCheckTotal(streetValueTmp.getShopCheckTotal() + item.getShopCheckTotal());
                    streetValueTmp.setGarbageCheckTotal(streetValueTmp.getGarbageCheckTotal() + item.getGarbageCheckTotal());
                    streetValueTmp.setCheckTimeOutTotal(streetValueTmp.getCheckTimeOutTotal() + item.getCheckTimeOutTotal());
                    streetValueTmp.setHiddenDangerTimes(streetValueTmp.getHiddenDangerTimes() + item.getHiddenDangerTimes());
                });
                finalResultStreetGroupList.add(streetValueTmp);
            });
            return finalResultStreetGroupList.stream().sorted(Comparator.comparing(SqfwDataStatisticStreetForAdminVO::getShopCheckTotal, Comparator.reverseOrder())).collect(Collectors.toList());
        }
        return finalResultStreetList.stream().sorted(Comparator.comparing(SqfwDataStatisticStreetForAdminVO::getShopCheckTotal, Comparator.reverseOrder())).collect(Collectors.toList());
    }

    /**
     * 商铺、巡查情况、隐患及整改情况统计(街道数据统计)
     */
    private SqfwDataStatisticStreetForAdminVO getStreetDeadlineRectForStreetData(Date startTime, Date endTime, Sys_user sysUser) {
        SqfwDataStatisticStreetForAdminVO resultStreet = new SqfwDataStatisticStreetForAdminVO();
        // 商铺检查
        StringBuffer sb = new StringBuffer(String.format(" fill_date >= '%s' AND fill_date <= '%s' AND type LIKE '%s' AND fill_date != '0001-01-01 00:00:00.000' ", startTime, endTime, "%安全排查%"));
        processStatisticCond(sb, sysUser);
        Cnd cnd1 = Cnd.NEW();
        cnd1.and(new Static(sb.toString()));
        Long shopTotal = (long) sqfwFormsummaryNewService.count(cnd1);
        resultStreet.setShopCheckTotal(shopTotal);
        log.info("SQL-getCompareChangeForStreetData4: province:{},city:{},district:{},county:{},community:{},sql:{},sqlREsult:{}", sysUser.getProvince(), sysUser.getCity(), sysUser.getDistrict(), sysUser.getCounty(), sysUser.getCommunity(), sb.toString(), shopTotal);

        // 垃圾分类巡查（次）
        sb = new StringBuffer(String.format(" fill_date >= '%s' AND fill_date <= '%s' AND type = '垃圾分类' AND fill_date != '0001-01-01 00:00:00.000' ", startTime, endTime));
        processStatisticCond(sb, sysUser);
        Cnd cnd2 = Cnd.NEW();
        cnd2.and(new Static(sb.toString()));
        Long garbageCheckTotal = (long) sqfwFormsummaryNewService.count(cnd2);
        resultStreet.setGarbageCheckTotal(garbageCheckTotal);
        log.info("SQL-getCompareChangeForStreetData5: province:{},city:{},district:{},county:{},community:{},sql:{},sqlREsult:{}", sysUser.getProvince(), sysUser.getCity(), sysUser.getDistrict(), sysUser.getCounty(), sysUser.getCommunity(), sb.toString(), garbageCheckTotal);

        // 燃气和用电情况使用
        sb = new StringBuffer(String.format(" fill_date >= '%s' AND fill_date <= '%s' AND type LIKE '%s' AND fill_date != '0001-01-01 00:00:00.000' AND param_data->>'fireAndElectricityUsage' != 'usage_of_fire_and_electricity_no'", startTime, endTime, "%安全排查%"));
        processStatisticCond(sb, sysUser);
        Cnd cnd3 = Cnd.NEW();
        cnd3.and(new Static(sb.toString()));
        Long gasCheckTotal = (long) sqfwFormsummaryNewService.count(cnd3);
        resultStreet.setGasCheckTotal(gasCheckTotal);
        log.info("SQL-getCompareChangeForStreetData6: province:{},city:{},district:{},county:{},community:{},sql:{},sqlREsult:{}", sysUser.getProvince(), sysUser.getCity(), sysUser.getDistrict(), sysUser.getCounty(), sysUser.getCommunity(), sb.toString(), gasCheckTotal);

        // 隐患情况（户数）
        sb = new StringBuffer("SELECT COUNT(DISTINCT param_data->>'address') nowData FROM shequ.\"sqfw_form_summary_new\"  WHERE fill_date >= @startTime AND fill_date <= @endTime AND type LIKE '%安全排查%' AND fill_date != '0001-01-01 00:00:00.000' AND (param_data->>'isRectified' IN ('2','3') OR issue_status = '1') ");
        processStatisticCond(sb, sysUser);
        Sql sql = Sqls.create(sb.toString());
        sql.setParam("startTime", startTime);
        sql.setParam("endTime", endTime);
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                Long nowData = 0L;
                if (rs.next()) {
                    nowData = rs.getLong("nowData");
                }
                return nowData;
            }
        });
        sqfwSummaryForAdminService.execute(sql);
        resultStreet.setHiddenDangerTotal(sql.getLong());
        log.info("SQL-getCompareChangeForStreetData7: province:{},city:{},district:{},county:{},community:{},sql:{},sqlREsult:{}", sysUser.getProvince(), sysUser.getCity(), sysUser.getDistrict(), sysUser.getCounty(), sysUser.getCommunity(), sql.toString(), sql.getLong());

        // 隐患情况(次数)
        sb = new StringBuffer(String.format(" fill_date >= '%s' AND fill_date <= '%s' AND type LIKE '%s' AND fill_date != '0001-01-01 00:00:00.000' AND (param_data->>'isRectified' IN ('2','3') OR issue_status = '1') ", startTime, endTime, "%安全排查%"));
        processStatisticCond(sb, sysUser);
        Cnd cnd4 = Cnd.NEW();
        cnd4.and(new Static(sb.toString()));
        Long hiddenDangerTimes = (long) sqfwFormsummaryNewService.count(cnd4);
        resultStreet.setHiddenDangerTimes(hiddenDangerTimes);
        log.info("SQL-getCompareChangeForStreetData8: province:{},city:{},district:{},county:{},community:{},sql:{},sqlREsult:{}", sysUser.getProvince(), sysUser.getCity(), sysUser.getDistrict(), sysUser.getCounty(), sysUser.getCommunity(), sb.toString(), hiddenDangerTimes);

        //限期整改情况
        sb = new StringBuffer(" SELECT COUNT(DISTINCT param_data->>'address') nowData FROM shequ.\"sqfw_form_summary_new\" WHERE fill_date >= @startTime AND fill_date <= @endTime  AND type LIKE '%安全排查%' AND fill_date != '0001-01-01 00:00:00.000'");
        processStatisticCond(sb, sysUser);
        sql = Sqls.create(sb.toString());
        sql.setParam("startTime", startTime);
        sql.setParam("endTime", endTime);
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                Long nowData = 0L;
                if (rs.next()) {
                    nowData = rs.getLong("nowData");
                }
                return nowData;
            }
        });
        sqfwSummaryForAdminService.execute(sql);
        resultStreet.setDeadlineRectTotal(sql.getLong());
        log.info("SQL-getCompareChangeForStreetData9: province:{},city:{},district:{},county:{},community:{},sql:{},sqlREsult:{}", sysUser.getProvince(), sysUser.getCity(), sysUser.getDistrict(), sysUser.getCounty(), sysUser.getCommunity(), sql.toString(), sql.getLong());

        //现场整改情况
        sb = new StringBuffer(" SELECT COUNT(DISTINCT param_data->>'address') nowData FROM shequ.\"sqfw_form_summary_new\" WHERE fill_date >= @startTime AND fill_date <= @endTime  AND type Like '%安全排查%' AND fill_date != '0001-01-01 00:00:00.000' ");
        processStatisticCond(sb, sysUser);
        sql = Sqls.create(sb.toString());
        sql.setParam("startTime", startTime);
        sql.setParam("endTime", endTime);
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                Long nowData = 0L;
                if (rs.next()) {
                    nowData = rs.getLong("nowData");
                }
                return nowData;
            }
        });
        sqfwSummaryForAdminService.execute(sql);
        resultStreet.setSceneRectTotal(sql.getLong());
        log.info("SQL-getCompareChangeForStreetData10: province:{},city:{},district:{},county:{},community:{},sql:{},sqlREsult:{}", sysUser.getProvince(), sysUser.getCity(), sysUser.getDistrict(), sysUser.getCounty(), sysUser.getCommunity(), sql.toString(), sql.getLong());

        // 巡查超时情况
        sb = new StringBuffer(String.format("SELECT COUNT(DISTINCT param_data->>'address') nowData FROM shequ.\"sqfw_form_summary_new\" WHERE fill_date >= '%s' AND fill_date <= '%s' AND type LIKE '%s' AND fill_date != '0001-01-01 00:00:00.000' AND fill_date < '%s' AND check_status = '1'", startTime, endTime, "%安全排查%", DateUtil.parse(CommonFormOfficeForAdminUtils.DATE_FORMAT.format(DateUtil.offsetDay(new Date(), -CommonFormOfficeForAdminUtils.TIME_OUT)))));
        processStatisticCond(sb, sysUser);
        sql = Sqls.create(sb.toString());
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                Long nowData = 0L;
                if (rs.next()) {
                    nowData = rs.getLong("nowData");
                }
                return nowData;
            }
        });
        sqfwSummaryForAdminService.execute(sql);
        resultStreet.setCheckTimeOutTotal(sql.getLong());
        log.info("SQL-getCompareChangeForStreetData11: province:{},city:{},district:{},county:{},community:{},sql:{},sqlREsult:{}", sysUser.getProvince(), sysUser.getCity(), sysUser.getDistrict(), sysUser.getCounty(), sysUser.getCommunity(), sql.toString(), sql.getLong());
        return resultStreet;
    }

    /**
     * 获取用户社区信息
     */
    private List<SqfwDataStatisticStreetForAdminVO> getUserCommunityInfo(Sys_user sysUser) {
        StringBuffer sb = new StringBuffer("SELECT DISTINCT county, community  FROM shequ.\"sys_user\" WHERE 1 = 1 ");
        processStatisticCond(sb, sysUser);
        sb.append(" ORDER BY community ASC");
        Sql sql = Sqls.create(sb.toString());
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                ResultSetMetaData metaData = rs.getMetaData();
                int columnCount = metaData.getColumnCount();
                List<SqfwDataStatisticStreetForAdminVO> resultCommunityList = new ArrayList<SqfwDataStatisticStreetForAdminVO>();
                while (rs.next()) {
                    SqfwDataStatisticStreetForAdminVO resultCommunity = new SqfwDataStatisticStreetForAdminVO();
                    for (int i = 0; i < columnCount; i++) {
                        resultCommunity.setCounty(rs.getString("county"));
                        resultCommunity.setCommunity(rs.getString("community"));
                    }
                    if (ZHISHU.equals(resultCommunity.getCounty())) {
                        // 如果街道是直属就不统计在内
                        continue;
                    }
                    resultCommunityList.add(resultCommunity);
                }
                return resultCommunityList;
            }
        });
        sysUserService.execute(sql);
        log.info("SQL-getCompareChangeForStreetData12: province:{},city:{},district:{},county:{},community:{},sql:{},sqlREsult:{}", sysUser.getProvince(), sysUser.getCity(), sysUser.getDistrict(), sysUser.getCounty(), sysUser.getCommunity(), sql.toString(), JSONObject.toJSONString(sql.getList(SqfwDataStatisticStreetForAdminVO.class)));
        return sql.getList(SqfwDataStatisticStreetForAdminVO.class);
    }

    /**
     * 累计复合六类人员
     */
    private void sumSixTypeMixPeopelNum(SqfwDataStatisticSixTypesForAdminVO resultVO, String sixTypes, Long num) {
        if (null == sixTypes || sixTypes.length() <= 1) {
            return;
        }
        Set<String> sixTypeSet = Sets.newHashSet(sixTypes.split("\\、"));
        for (String sixType : sixTypeSet) {
            switch (sixType) {
                case SIX_TYPE_DOUBLE_OLD:
                    resultVO.setOldDoubleTotal(resultVO.getOldDoubleTotal() + num);
                    break;
                case SIX_TYPE_SINGLE_OLD:
                    resultVO.setOldSingleTotal(resultVO.getOldSingleTotal() + num);
                    break;
                case SIX_TYPE_OLD:
                    resultVO.setOldTotal(resultVO.getOldTotal() + num);
                    break;
                case SIX_TYPE_DISA:
                    resultVO.setDisabledTotal(resultVO.getDisabledTotal() + num);
                    break;
                case SIX_TYPE_VUL:
                    resultVO.setVulTotal(resultVO.getVulTotal() + num);
                    break;
                case SIX_TYPE_MENT:
                    resultVO.setMentalTotal(resultVO.getMentalTotal() + num);
                    break;
                case SIX_TYPE_DISE:
                    resultVO.setDiseaseTotal(resultVO.getDiseaseTotal() + num);
                    break;
                case SIX_TYPE_DRINK:
                    resultVO.setDrinkTotal(resultVO.getDrinkTotal() + num);
                    break;
            }
        }
    }

    /**
     * 省市区街道社区查询条件处理
     *
     * @param baseCond
     * @param sysUser
     */
    private void processStatisticCond(StringBuffer baseCond, Sys_user sysUser) {
        if (!ZHISHU.equals(sysUser.getProvince()) && Strings.isNotBlank(sysUser.getProvince())) {
            baseCond.append(" AND province = '").append(sysUser.getProvince()).append("' ");
        }
        if (!ZHISHU.equals(sysUser.getCity()) && Strings.isNotBlank(sysUser.getCity())) {
            baseCond.append(" AND city = '").append(sysUser.getCity()).append("' ");
        }
        if (!ZHISHU.equals(sysUser.getDistrict()) && Strings.isNotBlank(sysUser.getDistrict())) {
            baseCond.append(" AND district = '").append(sysUser.getDistrict()).append("' ");
        }
        if (!ZHISHU.equals(sysUser.getCounty()) && Strings.isNotBlank(sysUser.getCounty())) {
            baseCond.append(" AND county = '").append(sysUser.getCounty()).append("' ");
        }
        if (!ZHISHU.equals(sysUser.getCommunity()) && Strings.isNotBlank(sysUser.getCommunity())) {
            baseCond.append(" AND community = '").append(sysUser.getCommunity()).append("' ");
        }
    }

    //-----------------------------------------------新大屏统计--------------------------------------------------------

    /**
     * 1.用户数量统计
     *
     * @return
     */
    @Override
    public Long getUserNum() {
        return Long.valueOf(sysUserService.count());
    }

    /**
     * 2.累计数量统计
     *
     * @return
     */
    @Override
    public Long getSummaryNum() {
        return Long.valueOf(sqfwSummaryForAdminService.count());
    }

    /**
     * 3.每日数据爬坡曲线：线图，数据累计量+每日流入量
     *
     * @return
     */
    @Override
    public List<SqfwDataStatisticInfoVO> getTotalAndEveryDayDataInfo() {
        int totalNum = 0;
        totalNum = sqfwSummaryForAdminService.count();

        StringBuffer sb = new StringBuffer("SELECT dateStr, num, SUM(num) OVER (ORDER BY dateStr)  +  @totalNum AS total_num FROM (");
        sb.append("SELECT substr(create_date,0,10) dateStr, count(1) num FROM shequ.\"sqfw_form_summary\" GROUP BY substr(create_date,0,10) ORDER BY dateStr DESC LIMIT 20) WHERE dateStr IS NOT NULL");
        Sql sql = Sqls.create(sb.toString());
        sql.setParam("totalNum", totalNum);
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                ResultSetMetaData metaData = rs.getMetaData();
                int columnCount = metaData.getColumnCount();
                List<SqfwDataStatisticInfoVO> resultList = new ArrayList<SqfwDataStatisticInfoVO>();
                while (rs.next()) {
                    SqfwDataStatisticInfoVO result = new SqfwDataStatisticInfoVO();
                    for (int i = 0; i < columnCount; i++) {
                        Date dateStr = rs.getDate("dateStr");
                        if (ObjectUtil.isEmpty(dateStr)) {
                            continue;
                        }
                        result.setDateStr(dateStr);
                        result.setCheckTotal(rs.getLong("num"));
                        result.setTotalNum(rs.getLong("total_num"));
                    }
                    resultList.add(result);
                }
                return resultList;
            }
        });
        sysUserService.execute(sql);
        log.info("SQL-getTotalAndEveryDayDataInfo: sql:{}", sql.toString());
        return sql.getList(SqfwDataStatisticInfoVO.class);
    }

    /**
     * 4.各类数据占比（意义在于看网格员投入时间最多的板块）：饼图/环图
     *
     * @return
     */
    @Override
    public SqfwDataStatisticPropDataInfoVO getCheckTypePropDataInfo() {
        StringBuffer sb = new StringBuffer("SELECT type, SUM(num) num FROM (SELECT type, COUNT(1) AS num FROM shequ.\"sqfw_form_summary\" GROUP BY type UNION ALL SELECT service_record_type type, COUNT(1) AS num FROM shequ.\"sqfw_report_file\" WHERE service_record_type = '12345' GROUP BY service_record_type) t GROUP BY type");
        Sql sql = Sqls.create(sb.toString());
        SqfwDataStatisticPropDataInfoVO sqfwDataStatisticPropDataInfoVO = new SqfwDataStatisticPropDataInfoVO();
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                ResultSetMetaData metaData = rs.getMetaData();
                int columnCount = metaData.getColumnCount();
                int totalNum = 0;
                List<SqfwDataStatisticInfoVO> resultList = new ArrayList<SqfwDataStatisticInfoVO>();
                while (rs.next()) {
                    SqfwDataStatisticInfoVO result = new SqfwDataStatisticInfoVO();
                    for (int i = 0; i < columnCount; i++) {
                        String type = rs.getString("type");
                        if (StringUtils.isEmpty(type)) {
                            type = "其他";
                        }
                        result.setCheckType(type);
                        result.setCheckTypeTotal(rs.getLong("num"));
                    }
                    resultList.add(result);
                }
                return resultList;
            }
        });
        sqfwSummaryForAdminService.execute(sql);
        log.info("SQL-getTotalPropDataInfo: sql:{},sqlREsult:{}", sql.toString(), JSONObject.toJSONString(sql.getList(SqfwDataStatisticInfoVO.class)));
        List<SqfwDataStatisticInfoVO> resultList = sql.getList(SqfwDataStatisticInfoVO.class);
        Long sum = resultList.stream().mapToLong(SqfwDataStatisticInfoVO::getCheckTypeTotal).sum();
        sqfwDataStatisticPropDataInfoVO.setCheckTotal(sum);
        sqfwDataStatisticPropDataInfoVO.setTypeTotal(sql.getList(SqfwDataStatisticInfoVO.class));
        return sqfwDataStatisticPropDataInfoVO;
    }

    /**
     * 5.网格员数据采集排情况
     *
     * @return
     */
    @Override
    public List<SqfwDataStatisticInfoVO> getGridPeopleCheckInfo() {
        StringBuffer sb = new StringBuffer("SELECT community, count(1) num FROM shequ.\"sqfw_form_summary\"  GROUP BY community ORDER BY num DESC");
        Sql sql = Sqls.create(sb.toString());
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                ResultSetMetaData metaData = rs.getMetaData();
                int columnCount = metaData.getColumnCount();
                List<SqfwDataStatisticInfoVO> resultList = new ArrayList<SqfwDataStatisticInfoVO>();
                while (rs.next()) {
                    SqfwDataStatisticInfoVO result = new SqfwDataStatisticInfoVO();
                    for (int i = 0; i < columnCount; i++) {
                        result.setCommunity(rs.getString("community"));
                        result.setCheckTotal(rs.getLong("num"));
                    }
                    resultList.add(result);
                }
                return resultList;
            }
        });
        sysUserService.execute(sql);
        return sql.getList(SqfwDataStatisticInfoVO.class);
    }

    /**
     * 6.12345动态：总量统计（含办结统计）+滚动表格
     *
     * @return
     */
    @Override
    public SqfwDataStatisticInfoVO getDynamicGovernmentServiceOnlineData() {
        SqfwDataStatisticInfoVO sqfwDataStatisticInfoVO = new SqfwDataStatisticInfoVO();
        Cnd cnd = Cnd.NEW();
        cnd.and(Sqfw_servicerecord::getType, "=", "12345");
        cnd.orderBy("createdat", "desc");
        cnd.limit(20);
        sqfwDataStatisticInfoVO.setSqfwServicerecordList(sqfwServicerecordService.query(cnd));
        return sqfwDataStatisticInfoVO;
    }

    /**
     * 7.安全巡查动态：总量统计（任务完成度）+滚动表格
     *
     * @return
     */
    @Override
    public SqfwDataStatisticInfoVO getDynamicSafetyCheckData() {
        // 总数
        StringBuffer sb = new StringBuffer("SELECT issue_status, count(1) num FROM shequ.\"sqfw_form_summary\" WHERE issue_status IN ('限期','现场','正常') AND type = '安全排查' GROUP BY issue_status");
        Sql sql = Sqls.create(sb.toString());
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                ResultSetMetaData metaData = rs.getMetaData();
                int columnCount = metaData.getColumnCount();
                SqfwDataStatisticInfoVO resultVO = new SqfwDataStatisticInfoVO();
                while (rs.next()) {
                    for (int i = 0; i < columnCount; i++) {
                        String issueStatus = rs.getString("issue_status");
                        if ("限期".equals(issueStatus)) {
                            resultVO.setWaitRectNum(rs.getLong("num"));
                        } else if ("现场".equals(issueStatus)) {
                            resultVO.setRectedNum(rs.getLong("num"));
                        } else if ("正常".equals(issueStatus)) {
                            resultVO.setNormalNum(rs.getLong("num"));
                        }
                    }
                }
                return resultVO;
            }
        });
        sqfwSummaryForAdminService.execute(sql);
        SqfwDataStatisticInfoVO sqfwDataStatisticInfoTmp = sql.getObject(SqfwDataStatisticInfoVO.class);
        SqfwDataStatisticInfoVO sqfwDataStatisticInfoVO = new SqfwDataStatisticInfoVO();
        sqfwDataStatisticInfoVO.setNormalNum(sqfwDataStatisticInfoTmp.getNormalNum());
        sqfwDataStatisticInfoVO.setRectedNum(sqfwDataStatisticInfoTmp.getRectedNum());
        sqfwDataStatisticInfoVO.setWaitRectNum(sqfwDataStatisticInfoTmp.getWaitRectNum());
        // 数据
        Cnd cnd = Cnd.NEW();
        cnd.and(Sqfw_formSummary::getType, "=", "安全排查");
        Set<String> set = Sets.newHashSet("限期", "现场", "正常");
        cnd.and(Sqfw_formSummary::getIssueStatus, "IN", set);
        cnd.limit(20);
        sqfwDataStatisticInfoVO.setSqfwFormSummaryList(sqfwSummaryForAdminService.query(cnd));
        return sqfwDataStatisticInfoVO;
    }

    /**
     * 7.社会治安
     *
     * @return
     */
    @Override
    public SqfwDataStatisticInfoVO getDynamicSocietySecData() {
        // 总数
        StringBuffer sb = new StringBuffer("SELECT issue_status, count(1) num FROM shequ.\"sqfw_form_summary\" WHERE issue_status IN ('限期','现场','正常') AND type = '社会治安' GROUP BY issue_status");
        Sql sql = Sqls.create(sb.toString());
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                ResultSetMetaData metaData = rs.getMetaData();
                int columnCount = metaData.getColumnCount();
                SqfwDataStatisticInfoVO resultVO = new SqfwDataStatisticInfoVO();
                while (rs.next()) {
                    for (int i = 0; i < columnCount; i++) {
                        String issueStatus = rs.getString("issue_status");
                        if ("限期".equals(issueStatus)) {
                            resultVO.setWaitRectNum(rs.getLong("num"));
                        } else if ("现场".equals(issueStatus)) {
                            resultVO.setRectedNum(rs.getLong("num"));
                        } else if ("正常".equals(issueStatus)) {
                            resultVO.setNormalNum(rs.getLong("num"));
                        }
                    }
                }
                return resultVO;
            }
        });
        sqfwSummaryForAdminService.execute(sql);
        SqfwDataStatisticInfoVO sqfwDataStatisticInfoTmp = sql.getObject(SqfwDataStatisticInfoVO.class);
        SqfwDataStatisticInfoVO sqfwDataStatisticInfoVO = new SqfwDataStatisticInfoVO();
        sqfwDataStatisticInfoVO.setNormalNum(sqfwDataStatisticInfoTmp.getNormalNum());
        sqfwDataStatisticInfoVO.setRectedNum(sqfwDataStatisticInfoTmp.getRectedNum());
        sqfwDataStatisticInfoVO.setWaitRectNum(sqfwDataStatisticInfoTmp.getWaitRectNum());
        // 数据
        Cnd cnd = Cnd.NEW();
        cnd.and(Sqfw_formSummary::getType, "=", "社会治安");
        Set<String> set = Sets.newHashSet("限期", "现场", "正常");
        cnd.and(Sqfw_formSummary::getIssueStatus, "IN", set);
        cnd.limit(20);
        sqfwDataStatisticInfoVO.setSqfwFormSummaryList(sqfwSummaryForAdminService.query(cnd));
        return sqfwDataStatisticInfoVO;
    }

    /**
     * 8.垃圾分类巡查动态：总量统计（任务完成度）+滚动表格
     *
     * @return
     */
    @Override
    public SqfwDataStatisticInfoVO getDynamicGarbageManageData() {
        // 总数
        StringBuffer sb = new StringBuffer("SELECT a17, count(1) num FROM shequ.\"sqfw_form_summary\" WHERE a17 IN ('限期','现场','正常') AND type = '垃圾分类' GROUP BY a17");
        Sql sql = Sqls.create(sb.toString());
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                ResultSetMetaData metaData = rs.getMetaData();
                int columnCount = metaData.getColumnCount();
                SqfwDataStatisticInfoVO resultVO = new SqfwDataStatisticInfoVO();
                while (rs.next()) {
                    for (int i = 0; i < columnCount; i++) {
                        String issueStatus = rs.getString("a17");
                        if ("限期".equals(issueStatus)) {
                            resultVO.setWaitRectNum(rs.getLong("num"));
                        } else if ("现场".equals(issueStatus)) {
                            resultVO.setRectedNum(rs.getLong("num"));
                        } else if ("正常".equals(issueStatus)) {
                            resultVO.setNormalNum(rs.getLong("num"));
                        }
                    }
                }
                return resultVO;
            }
        });
        sqfwSummaryForAdminService.execute(sql);
        SqfwDataStatisticInfoVO sqfwDataStatisticInfoTmp = sql.getObject(SqfwDataStatisticInfoVO.class);
        SqfwDataStatisticInfoVO sqfwDataStatisticInfoVO = new SqfwDataStatisticInfoVO();
        sqfwDataStatisticInfoVO.setNormalNum(sqfwDataStatisticInfoTmp.getNormalNum());
        sqfwDataStatisticInfoVO.setRectedNum(sqfwDataStatisticInfoTmp.getRectedNum());
        sqfwDataStatisticInfoVO.setWaitRectNum(sqfwDataStatisticInfoTmp.getWaitRectNum());
        // 数据
        Cnd cnd = Cnd.NEW();
        cnd.and(Sqfw_formSummary::getType, "=", "垃圾分类");
        Set<String> set = Sets.newHashSet("限期", "现场", "正常");
        cnd.and(Sqfw_formSummary::getA17, "IN", set);
        cnd.orderBy("create_date", "desc");
        cnd.limit(20);
        sqfwDataStatisticInfoVO.setSqfwFormSummaryList(sqfwSummaryForAdminService.query(cnd));
        return sqfwDataStatisticInfoVO;
    }

    /**
     * 9.隐患统计：数字
     *
     * @return
     */
    @Override
    public SqfwDataStatisticInfoVO getDynamicHiddenDangerData() {
        SqfwDataStatisticInfoVO sqfwDataStatisticInfoVO = new SqfwDataStatisticInfoVO();
        // 总数
        StringBuffer sb = new StringBuffer("SELECT county, community,issue_status,count(1) num  FROM ( ");
        sb.append("SELECT county, community, CASE WHEN issue_status = '现场' THEN '隐患' WHEN issue_status = '限期' THEN '隐患' ELSE '隐患' END AS issue_status, count(1) num FROM shequ.\"sqfw_form_summary\" where issue_status is not null AND issue_status != '正常' GROUP BY county, community,issue_status");
        sb.append(") GROUP BY county, community,issue_status ");
        Sql sql = Sqls.create(sb.toString());
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                ResultSetMetaData metaData = rs.getMetaData();
                int columnCount = metaData.getColumnCount();
                List<Sqfw_formSummary> sqfwFormSummaryList = new ArrayList<Sqfw_formSummary>();
                while (rs.next()) {
                    Sqfw_formSummary sqfwFormSummary = new Sqfw_formSummary();
                    for (int i = 0; i < columnCount; i++) {
                        sqfwFormSummary.setCounty(rs.getString("county"));
                        sqfwFormSummary.setCommunity(rs.getString("community"));
                        sqfwFormSummary.setIssueStatus(rs.getString("issue_status"));
                        sqfwFormSummary.setResidentNumber(rs.getInt("num"));
                    }
                    sqfwFormSummaryList.add(sqfwFormSummary);
                }
                return sqfwFormSummaryList;
            }
        });
        sysUserService.execute(sql);
        sqfwDataStatisticInfoVO.setSqfwFormSummaryList(sql.getList(Sqfw_formSummary.class));
        return sqfwDataStatisticInfoVO;
    }

    /**
     * 9.整改统计：饼图（整改未整改）
     *
     * @return
     */
    @Override
    public SqfwDataStatisticInfoVO getDynamicRectificationData() {
        StringBuffer sb = new StringBuffer("SELECT issue_status, count(1) num FROM shequ.\"sqfw_form_summary\" WHERE issue_status IN ('限期','现场','正常') GROUP BY issue_status");
        Sql sql = Sqls.create(sb.toString());
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                ResultSetMetaData metaData = rs.getMetaData();
                int columnCount = metaData.getColumnCount();
                SqfwDataStatisticInfoVO result = new SqfwDataStatisticInfoVO();
                while (rs.next()) {
                    for (int i = 0; i < columnCount; i++) {
                        String issueStatus = rs.getString("issue_status");
                        if ("限期".equals(issueStatus)) {
                            result.setWaitRectNum(rs.getLong("num"));
                        } else if ("现场".equals(issueStatus)) {
                            result.setRectedNum(rs.getLong("num"));
                        } else if ("正常".equals(issueStatus)) {
                            result.setNormalNum(rs.getLong("num"));
                        }
                    }
                }
                return result;
            }
        });
        sysUserService.execute(sql);
        log.info("SQL-getGridPeopleCheckInfo: sql:{},sqlREsult:{}", sql.toString(), JSONObject.toJSONString(sql.getObject(SqfwDataStatisticInfoVO.class)));
        return sql.getObject(SqfwDataStatisticInfoVO.class);
    }

    /**
     * 11.社区活动：总量统计+滚动表格+参加人数
     *
     * @return
     */
    @Override
    public SqfwDataStatisticInfoVO getDynamicCommunityActivitiesData() {
        SqfwDataStatisticInfoVO finalresultVO = new SqfwDataStatisticInfoVO();

        // 活动总数及各个社区总数
        Long rallyTotal = Long.valueOf(sqfwRallyForAdminService.count());
        finalresultVO.setCheckTotal(rallyTotal);

        // 各个社区报名人数
        StringBuffer sb = new StringBuffer("SELECT county||community AS community, count(1) num FROM public.\"sqfw_rally_sign\" GROUP BY county, community");
        Sql sql = Sqls.create(sb.toString());
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                ResultSetMetaData metaData = rs.getMetaData();
                int columnCount = metaData.getColumnCount();
                Map<String, Long> rallySignMap = new HashMap<String, Long>();
                while (rs.next()) {
                    for (int i = 0; i < columnCount; i++) {
                        rallySignMap.put(rs.getString("community"), rs.getLong("num"));
                    }
                }
                return rallySignMap;
            }
        });
        sqfwSummaryForAdminService.execute(sql);
        Map<String, Long> rallySignMap = sql.getObject(Map.class);

        // 各个社区活动总数
        sb = new StringBuffer("SELECT county||community AS community, count(1) num FROM public.\"sqfw_rally\" GROUP BY county, community ORDER BY num DESC");
        sql = Sqls.create(sb.toString());
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                ResultSetMetaData metaData = rs.getMetaData();
                int columnCount = metaData.getColumnCount();
                List<SqfwRallyVO> sqfwRallyList = new ArrayList<SqfwRallyVO>();
                while (rs.next()) {
                    SqfwRallyVO sqfwRally = new SqfwRallyVO();
                    for (int i = 0; i < columnCount; i++) {
                        String community = rs.getString("community");
                        sqfwRally.setCommunity(community);
                        sqfwRally.setRallyNum(rs.getLong("num"));
                        sqfwRally.setRallySignNum(rallySignMap.get(community));
                    }
                    sqfwRallyList.add(sqfwRally);
                }
                return sqfwRallyList;
            }
        });
        sqfwSummaryForAdminService.execute(sql);
        finalresultVO.setSqfwRallyVOList(sql.getList(SqfwRallyVO.class));
        return finalresultVO;
    }


    // 社区活动
    @Override
    public SqfwDataStatisticInfoVO getCommunityActivitiesData() {

        SqfwDataStatisticInfoVO finalResult = new SqfwDataStatisticInfoVO();
        // 按照场所分类
        StringBuffer sb = new StringBuffer("select  community,totalNum from (");
        sb.append(" SELECT count(1) as totalNum , county||community  as community FROM public.sqfw_rally where community not like'%测试%'  and county not like'%直属%'  group by community,county");
        sb.append(" )  order by   totalNum desc  ");
        Sql sql = Sqls.create(sb.toString());
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                ResultSetMetaData metaData = rs.getMetaData();
                int columnCount = metaData.getColumnCount();
                Map<String, Long> houseCheckTypeMap = new HashMap<String, Long>();
                while (rs.next()) {
                    for (int i = 0; i < columnCount; i++) {
                        houseCheckTypeMap.put(rs.getString("community"), rs.getLong("totalNum"));
                    }
                }
                return houseCheckTypeMap;
            }
        });
        sqfwSummaryForAdminService.execute(sql);
        Map<String, Long> houseCheckTypeMap = sql.getObject(Map.class);
        finalResult.setPlaceMap(houseCheckTypeMap);
        return finalResult;


    }

    /**
     * 12.商铺分级管理：柱状图
     *
     * @return
     */
    @Override
    public SqfwDataStatisticInfoVO getDynamicShopManageData() {
        SqfwDataStatisticInfoVO finalResult = new SqfwDataStatisticInfoVO();
        // 按照场所分类
        StringBuffer sb = new StringBuffer("SELECT place, SUM(num) num FROM (");
        sb.append(" SELECT CASE WHEN a5 = '餐饮' THEN '餐饮' WHEN a5 = '餐饮店' THEN '餐饮' WHEN a5 = '奶茶店' THEN '餐饮' WHEN a5 = '零售' THEN '零售' WHEN a5 = '商店' THEN '零售' WHEN a5 = '便利店' THEN '零售' WHEN a5 = '生鲜' THEN '零售' WHEN a5 = '旅馆' THEN '旅馆' WHEN a5 = '重点场所' THEN '重点场所' WHEN a5 = '大型商场、超市、酒店' THEN '重点场所' WHEN a5 = '幼儿园、寄宿制学校、社会福利机构' THEN '重点场所' WHEN a5 = '医院、诊所、卫生服务站' THEN '重点场所' WHEN a5 = '劳动密集型企业、多业态混合经营场所' THEN '重点场所' WHEN a5 = '其他重点消防安全场所' THEN '重点场所' WHEN a5 = '物管' THEN '重点场所' WHEN a5 = '酒店旅馆、餐饮饭店' THEN '重点场所' WHEN a5 = '医院、养老院、学校、幼儿园' THEN '重点场所' WHEN a5 = '服务' THEN '服务' WHEN a5 = '美容、足疗、洗浴、按摩' THEN '服务' WHEN a5 = '快递' THEN '服务' WHEN a5 = '美容院' THEN '服务' WHEN a5 = '美容' THEN '服务' WHEN a5 = '汽修' THEN '服务' WHEN a5 = '修理' THEN '服务' WHEN a5 = '汽修' THEN '服务' WHEN a5 = '广告设计' THEN '服务' WHEN a5 = '中介' THEN '服务' WHEN a5 = '房地产' THEN '服务' ELSE '其他' END AS place, COUNT(1) num FROM shequ.\"sqfw_form_summary\" where county in ('大营路街道','云潭街道') AND type != '入户调查' GROUP BY a5");
        sb.append(" UNION ALL");
        sb.append(" SELECT CASE WHEN a6 = '餐饮' THEN '餐饮' WHEN a6 = '餐饮店' THEN '餐饮' WHEN a6 = '奶茶店' THEN '餐饮' WHEN a6 = '零售' THEN '零售' WHEN a6 = '商店' THEN '零售' WHEN a6 = '便利店' THEN '零售' WHEN a6 = '生鲜' THEN '零售'  WHEN a6 = '旅馆' THEN '旅馆' WHEN a6 = '重点场所' THEN '重点场所' WHEN a6 = '大型商场、超市、酒店' THEN '重点场所' WHEN a6 = '幼儿园、寄宿制学校、社会福利机构' THEN '重点场所' WHEN a6 = '医院、诊所、卫生服务站' THEN '重点场所' WHEN a6 = '劳动密集型企业、多业态混合经营场所' THEN '重点场所' WHEN a6 = '其他重点消防安全场所' THEN '重点场所' WHEN a6 = '物管' THEN '重点场所' WHEN a6 = '酒店旅馆、餐饮饭店' THEN '重点场所' WHEN a6 = '医院、养老院、学校、幼儿园' THEN '重点场所' WHEN a6 = '服务' THEN '服务' WHEN a6 = '美容、足疗、洗浴、按摩' THEN '服务' WHEN a6 = '快递' THEN '服务' WHEN a6 = '美容院' THEN '服务' WHEN a6 = '美容' THEN '服务' WHEN a6 = '汽修' THEN '服务' WHEN a6 = '修理' THEN '服务' WHEN a6 = '汽修' THEN '服务' WHEN a6 = '广告设计' THEN '服务' WHEN a6 = '中介' THEN '服务' WHEN a6 = '房地产' THEN '服务' ELSE '其他' END AS place, COUNT(1) num FROM shequ.\"sqfw_form_summary\" where county='威清门街道' AND type != '入户调查' GROUP BY a6");
        sb.append(" UNION ALL");
        sb.append(" SELECT CASE WHEN a16 = '餐饮' THEN '餐饮' WHEN a16 = '餐饮店' THEN '餐饮' WHEN a16 = '奶茶店' THEN '餐饮' WHEN a16 = '零售' THEN '零售' WHEN a16 = '商店' THEN '零售' WHEN a16 = '便利店' THEN '零售' WHEN a16 = '生鲜' THEN '零售'  WHEN a16 = '旅馆' THEN '旅馆' WHEN a16 = '重点场所' THEN '重点场所' WHEN a16 = '大型商场、超市、酒店' THEN '重点场所' WHEN a16 = '幼儿园、寄宿制学校、社会福利机构' THEN '重点场所' WHEN a16 = '医院、诊所、卫生服务站' THEN '重点场所' WHEN a16 = '劳动密集型企业、多业态混合经营场所' THEN '重点场所' WHEN a16 = '其他重点消防安全场所' THEN '重点场所' WHEN a16 = '物管' THEN '重点场所' WHEN a16 = '酒店旅馆、餐饮饭店' THEN '重点场所' WHEN a16 = '医院、养老院、学校、幼儿园' THEN '重点场所' WHEN a16 = '服务' THEN '服务' WHEN a16 = '美容、足疗、洗浴、按摩' THEN '服务' WHEN a16 = '快递' THEN '服务' WHEN a16 = '美容院' THEN '服务' WHEN a16 = '美容' THEN '服务' WHEN a16 = '汽修' THEN '服务' WHEN a16 = '修理' THEN '服务' WHEN a16 = '汽修' THEN '服务' WHEN a16 = '广告设计' THEN '服务' WHEN a16 = '中介' THEN '服务' WHEN a16 = '房地产' THEN '服务' ELSE '其他' END AS place, COUNT(1) num FROM shequ.\"sqfw_form_summary\" where county='花果园街道' AND type != '入户调查' GROUP BY a16");
        sb.append(") GROUP BY place");
        Sql sql = Sqls.create(sb.toString());
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                ResultSetMetaData metaData = rs.getMetaData();
                int columnCount = metaData.getColumnCount();
                Map<String, Long> placeMap = new HashMap<String, Long>();
                while (rs.next()) {
                    for (int i = 0; i < columnCount; i++) {
                        placeMap.put(rs.getString("place"), rs.getLong("num"));
                    }
                }
                return placeMap;
            }
        });
        sqfwRallyForAdminService.execute(sql);
        Map<String, Long> placeMap = sql.getObject(Map.class);
        finalResult.setPlaceMap(placeMap);

        // 按照场所分类
        sb = new StringBuffer("SELECT fire_elect, SUM(num) num FROM (");
        sb.append(" SELECT CASE WHEN a17 = '无' THEN '无' WHEN a17 = '用电' THEN '用电' WHEN a17 = '瓶装液化气' THEN '瓶装液化气' WHEN a17 = '液化石油气' THEN '瓶装液化气' WHEN a17 = '使用液化气' THEN '瓶装液化气' WHEN a17 = '管道燃气' THEN '管道燃气' ELSE '其他' END AS fire_elect, COUNT(1) num FROM shequ.\"sqfw_form_summary\" where county in ('威清门街道','花果园街道') AND type != '入户调查' GROUP BY a17");
        sb.append(" UNION ALL");
        sb.append(" SELECT CASE WHEN a7 = '无' THEN '无' WHEN a7 = '用电' THEN '用电' WHEN a7 = '瓶装液化气' THEN '瓶装液化气' WHEN a7 = '液化石油气' THEN '瓶装液化气' WHEN a7 = '使用液化气' THEN '瓶装液化气' WHEN a7 = '管道燃气' THEN '管道燃气' ELSE '其他' END AS fire_elect, COUNT(1) num FROM shequ.\"sqfw_form_summary\" where county='大营路街道' AND type != '入户调查' GROUP BY a7");
        sb.append(" UNION ALL");
        sb.append(" SELECT CASE WHEN a6 = '无' THEN '无' WHEN a6 = '用电' THEN '用电' WHEN a6 = '瓶装液化气' THEN '瓶装液化气' WHEN a6 = '液化石油气' THEN '瓶装液化气' WHEN a6 = '使用液化气' THEN '瓶装液化气' WHEN a6 = '管道燃气' THEN '管道燃气' ELSE '其他' END AS fire_elect, COUNT(1) num FROM shequ.\"sqfw_form_summary\" where county='云潭街道' AND type != '入户调查' GROUP BY a6");
        sb.append(") GROUP BY fire_elect");
        sql = Sqls.create(sb.toString());
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                ResultSetMetaData metaData = rs.getMetaData();
                int columnCount = metaData.getColumnCount();
                Map<String, Long> fireElectMap = new HashMap<String, Long>();
                while (rs.next()) {
                    for (int i = 0; i < columnCount; i++) {
                        fireElectMap.put(rs.getString("fire_elect"), rs.getLong("num"));
                    }
                }
                return fireElectMap;
            }
        });
        sqfwRallyForAdminService.execute(sql);
        Map<String, Long> fireElectMap = sql.getObject(Map.class);
        finalResult.setFireElectMap(fireElectMap);
        return finalResult;
    }

    /**
     * 13.重点人员管理：轮播展示数据
     *
     * @return
     */
    @Override
    public SqfwDataStatisticInfoVO getDynamicImportPeopleData() {
        SqfwDataStatisticInfoVO sqfwDataStatisticInfoVO = new SqfwDataStatisticInfoVO();
        // 按照特殊人员标识分类
        StringBuffer sb = new StringBuffer("SELECT special_mark, COUNT(1) num FROM shequ.\"sqfw_censuspaper\" WHERE special_mark != '正常' GROUP BY special_mark");
        Sql sql = Sqls.create(sb.toString());
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                ResultSetMetaData metaData = rs.getMetaData();
                int columnCount = metaData.getColumnCount();
                SqfwDataStatisticInfoVO sqfwDataStatisticInfoVOTmp = new SqfwDataStatisticInfoVO();
                while (rs.next()) {
                    for (int i = 0; i < columnCount; i++) {
                        sumSpecialPeopelNum(sqfwDataStatisticInfoVOTmp, rs.getString("special_mark"));
                    }
                }
                return sqfwDataStatisticInfoVOTmp;
            }
        });
        sqfwSummaryForAdminService.execute(sql);
        SqfwDataStatisticInfoVO sqfwDataStatisticInfoVOTmp = sql.getObject(SqfwDataStatisticInfoVO.class);
        BeanUtil.copyProperties(sqfwDataStatisticInfoVOTmp, sqfwDataStatisticInfoVO);

        // 统计探访次数
        sb = new StringBuffer("SELECT a15 address, COUNT(1) num FROM shequ.\"sqfw_form_summary\" WHERE a15 IN (SELECT detail_address FROM shequ.\"sqfw_censuspaper\" WHERE detail_address IS NOT NULL ORDER BY create_date DESC LIMIT 20) GROUP BY a15");
        sql = Sqls.create(sb.toString());
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                ResultSetMetaData metaData = rs.getMetaData();
                int columnCount = metaData.getColumnCount();
                Map<String, Long> houseCheckNumMap = new HashMap<String, Long>();
                while (rs.next()) {
                    for (int i = 0; i < columnCount; i++) {
                        houseCheckNumMap.put(rs.getString("address"), rs.getLong("num"));
                    }
                }
                return houseCheckNumMap;
            }
        });
        sqfwSummaryForAdminService.execute(sql);
        Map<String, Long> houseCheckTypeMap = sql.getObject(Map.class);

        // 重点人员
        Cnd cnd = Cnd.NEW();
        cnd.and(Sqfw_cenSusPaper::getSpecialMark, "!=", "正常");
        Long importPeopleTotal = Long.valueOf(sqfwCenSusPaperService.count());
        sqfwDataStatisticInfoVO.setImportPeopleTotal(importPeopleTotal);

        cnd.limit(20);
        cnd.orderBy("create_date", "desc");
        List<Sqfw_cenSusPaper> sqfwCenSusPaperList = sqfwCenSusPaperService.query(cnd);
        List<SqfwCenSusPaperVO> sqfwCenSusPaperVOList = new ArrayList<SqfwCenSusPaperVO>();
        sqfwCenSusPaperList.forEach(s -> {
            SqfwCenSusPaperVO sqfwCenSusPaperVO = new SqfwCenSusPaperVO();
            BeanUtil.copyProperties(s, sqfwCenSusPaperVO);
            sqfwCenSusPaperVO.setCheckNum(houseCheckTypeMap.get(s.getDetailAddress()));
            sqfwCenSusPaperVOList.add(sqfwCenSusPaperVO);
        });
        sqfwDataStatisticInfoVO.setSqfwCenSusPaperVOList(sqfwCenSusPaperVOList);
        return sqfwDataStatisticInfoVO;
    }

    /**
     * 13.入户调查类型：垃圾分类宣传、消防安全宣传、入户安全巡查、特殊人员巡查
     *
     * @return
     */
    @Override
    public SqfwDataStatisticInfoVO getHouseCheckTypeGroupData() {
        SqfwDataStatisticInfoVO finalResult = new SqfwDataStatisticInfoVO();
        // 按照场所分类
        StringBuffer sb = new StringBuffer("SELECT type, SUM(num) num FROM (");
        sb.append(" SELECT type, COUNT(1) num FROM shequ.\"sqfw_form_summary\" where type != '入户调查' GROUP BY type");
        sb.append(" UNION ALL");
        sb.append(" SELECT CASE WHEN special_mark != '正常' THEN '特殊人员' END AS type , COUNT(1) num FROM shequ.\"sqfw_censuspaper\" where special_mark is not null and special_mark !='正常' GROUP BY special_mark");
        sb.append(") GROUP BY type");
        Sql sql = Sqls.create(sb.toString());
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                ResultSetMetaData metaData = rs.getMetaData();
                int columnCount = metaData.getColumnCount();
                Map<String, Long> houseCheckTypeMap = new HashMap<String, Long>();
                while (rs.next()) {
                    for (int i = 0; i < columnCount; i++) {
                        houseCheckTypeMap.put(rs.getString("type"), rs.getLong("num"));
                    }
                }
                return houseCheckTypeMap;
            }
        });
        sqfwSummaryForAdminService.execute(sql);
        Map<String, Long> houseCheckTypeMap = sql.getObject(Map.class);
        finalResult.setPlaceMap(houseCheckTypeMap);
        return finalResult;
    }

    /**
     * 14.重点单位、场所：总量统计+滚动表格
     *
     * @return
     */
    @Override
    public SqfwDataStatisticInfoVO getDynamicImportUnitData() {
        SqfwDataStatisticInfoVO sqfwDataStatisticInfoVO = new SqfwDataStatisticInfoVO();
        // 重点场所
        Cnd cnd = Cnd.NEW();
        Set<String> set = Sets.newHashSet("大型商场、超市、酒店", "幼儿园、寄宿制学校、社会福利机构", "医院、诊所、卫生服务站", "劳动密集型企业、多业态混合经营场所", "其他重点消防安全场所");
        cnd.and(Sqfw_formSummary::getA5, "IN", set);
        Long importUnitTotal = Long.valueOf(sqfwSummaryForAdminService.count());
        sqfwDataStatisticInfoVO.setImportUnitTotal(importUnitTotal);

        // 重点场所数据
        cnd.orderBy("create_date", "desc");
        cnd.limit(20);
        sqfwDataStatisticInfoVO.setSqfwFormSummaryList(sqfwSummaryForAdminService.query(cnd));
        return sqfwDataStatisticInfoVO;
    }

    /**
     * 15.覆盖街道
     *
     * @return
     */
    @Override
    public Long getCoverStreet() {
        StringBuffer sb = new StringBuffer("SELECT COUNT(1) num from (SELECT DISTINCT county FROM shequ.\"sqfw_form_summary\")");
        Sql sql = Sqls.create(sb.toString());
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                if (rs.next()) {
                    Long num = rs.getLong("num");
                    return num;
                }
                return 0;
            }
        });
        sqfwSummaryForAdminService.execute(sql);
        return sql.getLong();
    }

    /**
     * 16.覆盖社区
     *
     * @return
     */
    @Override
    public Long getCoverCommunity() {
        StringBuffer sb = new StringBuffer("SELECT COUNT(1) num from (SELECT DISTINCT community FROM shequ.\"sqfw_form_summary\")");
        Sql sql = Sqls.create(sb.toString());
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                if (rs.next()) {
                    Long num = rs.getLong("num");
                    return num;
                }
                return 0;
            }
        });
        sqfwSummaryForAdminService.execute(sql);
        return sql.getLong();
    }

    /**
     * 17.覆盖居民
     *
     * @return
     */
    @Override
    public Long getCoverResident() {
        Long peopleNum = Long.valueOf(sqfwCenSusPaperService.count());
        return peopleNum;
    }

    /**
     * 18.覆盖企业商户
     *
     * @return
     */
    @Override
    public Long getCoverEnterprises() {
        StringBuffer sb = new StringBuffer("SELECT COUNT(1) num FROM shequ.\"sqfw_form_summary\" WHERE type != '入户调查'");
        Sql sql = Sqls.create(sb.toString());
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                if (rs.next()) {
                    Long num = rs.getLong("num");
                    return num;
                }
                return 0;
            }
        });
        sqfwSummaryForAdminService.execute(sql);
        return sql.getLong();
    }

    /**
     * 19.覆盖户数
     *
     * @return
     */
    @Override
    public Long getCoverHouseholds() {
        StringBuffer sb = new StringBuffer("SELECT COUNT(1) num from (SELECT DISTINCT a3 FROM shequ.\"sqfw_form_summary\" )");
        Sql sql = Sqls.create(sb.toString());
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                if (rs.next()) {
                    Long num = rs.getLong("num");
                    return num;
                }
                return 0;
            }
        });
        sqfwSummaryForAdminService.execute(sql);
        return sql.getLong();
    }

    /**
     * 20.本周数据
     *
     * @return
     */
    @Override
    public Long getWeekNum() {
        StringBuffer sb = new StringBuffer("SELECT COUNT(1) num FROM shequ.sqfw_form_summary WHERE create_date >= date_trunc('week', current_date) + '1 day'::interval AND create_date < date_trunc('week', current_date) + '1 week'::interval + '1 day'::interval");
        Sql sql = Sqls.create(sb.toString());
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                if (rs.next()) {
                    Long num = rs.getLong("num");
                    return num;
                }
                return 0;
            }
        });
        sqfwSummaryForAdminService.execute(sql);
        return sql.getLong();
    }

    /**
     * summary详情查询
     *
     * @param id
     * @return
     */
    @Override
    public Sqfw_formSummary getSummaryDetail(String id) {
        return sqfwSummaryForAdminService.fetch(id);
    }

    /**
     * 累计重点符合人员
     */
    private void sumSpecialPeopelNum(SqfwDataStatisticInfoVO resultVO, String specialTypes) {
        if (null == specialTypes || specialTypes.length() <= 1) {
            return;
        }
        int num = 1;
        Set<String> sixTypeSet = Sets.newHashSet(specialTypes.split("\\、"));
        for (String sixType : sixTypeSet) {
            switch (sixType) {
                case SIX_TYPE_DOUBLE_OLD:
                    resultVO.setSpecialDoubleOld(resultVO.getSpecialDoubleOld() + num);
                    break;
                case SIX_TYPE_SINGLE_OLD:
                    resultVO.setSpecialSingleOld(resultVO.getSpecialSingleOld() + num);
                    break;
                case SIX_TYPE_DISA:
                    resultVO.setSpecialDisa(resultVO.getSpecialDisa() + num);
                    break;
                case SIX_TYPE_VUL:
                    resultVO.setSpecialVul(resultVO.getSpecialVul() + num);
                    break;
                case SIX_TYPE_MENT:
                    resultVO.setSpecialMent(resultVO.getSpecialMent() + num);
                    break;
                case SIX_TYPE_DISE:
                    resultVO.setSpecialDise(resultVO.getSpecialDise() + num);
                    break;
                case SIX_TYPE_DRINK:
                    resultVO.setSpecialDrink(resultVO.getSpecialDrink() + num);
                    break;
                case SPECIAL_TYPE_ONE:
                    resultVO.setSpecialOne(resultVO.getSpecialOne() + num);
                    break;
                case SPECIAL_TYPE_STAY:
                    resultVO.setSpecialStay(resultVO.getSpecialStay() + num);
                    break;
                case SPECIAL_TYPE_ENTERPRISE:
                    resultVO.setSpecialEnterprise(resultVO.getSpecialEnterprise() + num);
                    break;
                case SPECIAL_TYPE_PREG:
                    resultVO.setSpecialPreg(resultVO.getSpecialPreg() + num);
                    break;
            }
        }
    }
}